const inputStr = readline();

const displayNum = parseInt(readline());

const convertDisplayStr = (str, displayCount) => {
    const tL = str.length;
    const tC = str.split('');
    const chineseChatList = tC.filter(c => /[\u4E00-\u9FA5]|[\uFE30-\uFFA0]/gi.exec(c));
    if (chineseChatList.length + tL <= displayCount) {
        return str;
    }
    // need truncate
    if (displayCount <= 3) {
        return '...';
    }
    // reversed chat count
    const rCL = Array(tL).fill(0);
    const cCL = Array(tL).fill(0);
    for (let i = tL - 1; i >= 0; i--) {
        const cC = tC[i];
        const cCt = /[\u4E00-\u9FA5]|[\uFE30-\uFFA0]/gi.exec(cC) ? 2 : 1;
        cCL[i] = cCt;
        if (i === tL - 1) {
            rCL[i] = cCt;
        } else {
            rCL[i] = cCt + rCL[i + 1];
        }
    }
    let tempOutputStr = '';
    let cCt = 0;
    const appendCount = 3;
    const appendStr = '...';
    for (let i = 0; i < tL; i++) {
        const cC = tC[i];
        if (rCL[i] > appendCount) {
            if (cCt + cCL[i] + appendCount > displayCount) {
                tempOutputStr += appendStr;
                break;
            } else {
                tempOutputStr += cC;
                cCt += cCL[i];
            }
        } else {
            tempOutputStr += cC;
            cCt += cCL[i];
        }
    }
    return tempOutputStr;
}

print(convertDisplayStr(inputStr, displayNum));